﻿@model SimpleForum.Data.Models.ViewModels.UserViewModel

@{
    ViewBag.Title = Model.User.UserName;
}

<div id="content-top">
    <h2>@ViewBag.Title</h2>
    <ul id="tabs">
        <li><a href="/user/@Model.User.Id/@Model.User.UserName.Slugify()/profile">profile</a></li>
        <li><a href="/user/@Model.User.Id/@Model.User.UserName.Slugify()/statistics">statistics</a></li>
    </ul>

    <span class="clearfix">&nbsp;</span>
</div>

<div class="box" id="user-@Model.User.Id">
    <div class="box-container">
        @{ Html.RenderPartial("ViewParts/" + @Model.CurrentView, Model); }
    </div>
</div>

@Html.Resource(@<script type="text/javascript" src="@Url.ThemeContent("JS/jquery.infobox.js")"></script>, "js")
@Html.Resource(@<script type="text/javascript">
    $(document).ready(function () {
        $('#tabs li a').click(function (event) {
            event.preventDefault();
            $('.box .box-container').infobox().load($(this).attr('href'));
        });
    });
</script>, "js")

@if (Model.IsSelf) {
    @Html.Resource(@<script type="text/javascript" src="@Url.ThemeContent("JS/showdown.js")"></script>, "js")
    @Html.Resource(@<script type="text/javascript">
        $(document).ready(function () {
            $('#tabs li a').click(function () {
                $('.box .box-container').infobox().load($(this).attr('href'));
                return false;
            });
            $('#bio').live('click', function () {
                $('#bio-text').hide();
                $('#update-bio').show();
            });
            $('#update-bio button').live('click', function () {
                var biotext = $('#update-bio textarea').val();
                $(this).attr('disabled', 'disabled');
                $('#bio').infobox();
                $.post('/User/SaveBio', { bio: biotext }, function () {
                    $('#update-bio').hide();
                    $('#bio').infobox({ text: 'your bio has been updated' });
                    $('#update-bio button').removeAttr('disabled');

                    $('#bio-text').show().html(new Attacklab.showdown.converter().makeHtml(biotext));
                });
            });
        });
    </script>, "js")
}